1 program problem11203_2doIntento (input, output);
\r
6 Function StrToInt(Const S: String): Integer;
\r
14 function ocurrencias(const s: string; const c:char) : integer;
\r
19 for i:=0 to length(s) do
\r
25 function isTheorem(s : string) : boolean;
\r
27 i, x, y, z : integer;
\r
28 posM, posE : integer;
\r
31 if (ocurrencias(s, 'M') = 1) and (ocurrencias(s, 'E') = 1) and (ocurrencias(s, '?') >= 4) then
\r
33 x := 0; y := 0; z := 0;
\r
34 posM := pos('M', s);
\r
35 for i:=1 to posM-1 do
\r
36 if (s[i] = '?') then
\r
40 s := copy(s, posM + 1, length(s));
\r
41 posE := pos('E', s);
\r
42 for i:=1 to posE-1 do
\r
43 if (s[i] = '?') then
\r
47 s := copy(s, posE + 1, length(s));
\r
48 for i:=1 to length(s) do
\r
49 if (s[i] = '?') then
\r
54 result := (x + y = z) and (x*y*z <> 0);
\r
60 i, principalLoop : integer;
\r
62 correctChars : Set of char;
\r
67 //reset(input, 'input.txt');
\r
68 //reset(output, 'out.txt');
\r
69 correctChars := ['M', 'E', '?'];
\r
71 howMany := strToInt(line);
\r
73 for principalLoop := 1 to howMany do
\r
77 for i := 1 to length(line) do
\r
78 if not (line[i] in correctChars) then
\r
81 writeLn('no-theorem')
\r
84 if isTheorem(line) then
\r
87 writeLn('no-theorem');
\r